/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import javax.swing.JOptionPane;
import src.LinkedLists;

/**
 *
 * @author Strauzen
 */
public class VentanaAlias extends javax.swing.JFrame {

    VentanaPersonaje vp;
    
    /**
     * Creates new form VentanaAlias
     */
    public VentanaAlias(VentanaPersonaje vp) {
        this.vp = vp;
        initComponents();
    }

        private boolean comprobar(){
        String mensaje = "";
        boolean resultado = false;
        
        if(this.jTextField_vaAlias.getText().equals(""))
            mensaje += "Por favor rellene el campo de alias\n\n";
        
        if ("".equals(mensaje))
            resultado =true;
        else
            JOptionPane.showMessageDialog(null, mensaje);
        
        return resultado;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel_vaAlias = new javax.swing.JLabel();
        jTextField_vaAlias = new javax.swing.JTextField();
        jButton_vaTerminar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Añadir Alias");
        setName("Añadir Alias"); // NOI18N

        jLabel_vaAlias.setText("Alias");

        jButton_vaTerminar.setText("Terminar");
        jButton_vaTerminar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_vaTerminarMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel_vaAlias)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField_vaAlias, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(125, 125, 125)
                .addComponent(jButton_vaTerminar)
                .addContainerGap(142, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_vaAlias)
                    .addComponent(jTextField_vaAlias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton_vaTerminar))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_vaTerminarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_vaTerminarMouseClicked
        // TODO add your handling code here:
        if(comprobar()){
            this.setVisible(false);
            vp.setVisible(true);
            LinkedLists.anadeAliaParaPersonajes(jTextField_vaAlias.getText());
            this.dispose();
        }
    }//GEN-LAST:event_jButton_vaTerminarMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_vaTerminar;
    private javax.swing.JLabel jLabel_vaAlias;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField_vaAlias;
    // End of variables declaration//GEN-END:variables
}
